package com.example.test.operate.util;

/*************************************************************************
 *                  HONGLING CAPITAL CONFIDENTIAL AND PROPRIETARY
 *
 *                COPYRIGHT (C) HONGLING CAPITAL CORPORATION 2012
 *    ALL RIGHTS RESERVED BY HONGLING CAPITAL CORPORATION. THIS PROGRAM
 * MUST BE USED  SOLELY FOR THE PURPOSE FOR WHICH IT WAS FURNISHED BY
 * HONGLING CAPITAL CORPORATION. NO PART OF THIS PROGRAM MAY BE REPRODUCED
 * OR DISCLOSED TO OTHERS,IN ANY FORM, WITHOUT THE PRIOR WRITTEN
 * PERMISSION OF HONGLING CAPITAL CORPORATION. USE OF COPYRIGHT NOTICE
 * DOES NOT EVIDENCE PUBLICATION OF THE PROGRAM.
 *                  HONGLING CAPITAL CONFIDENTIAL AND PROPRIETARY
 *************************************************************************/

import java.util.List;

/**
 *<desc>
 *      page分页模型
 *</desc>
 *
 * @date 2016-4-8 09:12
 */
public class Page<T> {
    private PageUtils page = new PageUtils();
    private List<T> rows;


    public PageUtils getPage() {
        return page;
    }

    public void setPage(PageUtils page) {
        this.page = page;
    }

    public List<T> getRows() {
        return rows;
    }

    public Page(){

    }

    public Page(String currentPage,String pageSize){
        this.page.setPageSize(pageSize);
        this.page.setCurrentPage(currentPage);
    }

    /**
     * <desc>
     *      填充数据
     * </desc>
     * @param data
     * @param pageCount
     */
    public void setRows(List<T> data,Integer pageCount) {
        this.rows = data;
        //设置总条数
        this.page.setTotalNumber(pageCount);
        //设置总页数
        this.page.setTotalPage((this.page.getTotalNumber() + this.page.getPageSize() - 1) / this.page.getPageSize());
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    @Override
    public String toString() {
        return "Page [page=" + page + ", list=" + rows + "]";
    }



}
